#include <stdio.h>
#include "connected_layer.h"
#include "input_layer.h"
#include "network.h"

void add_connected_layer(network *net)
{
    int batch,inputs, outputs;
    int batch_normalize = 0;
    int adam=0;
    char activation_s[]="relu";
    ACTIVATION activation = get_activation(activation_s);
    outputs = 2;
    inputs = 7;
    batch=1;
    
    layer l = make_connected_layer(batch, inputs, outputs, activation, batch_normalize, adam);
    net->layers[1] = l;

    int i,j;
    printf("weight:\n");
    for (i = 0; i < outputs; i++) {
        for (j = 0; j < inputs; j++) {
            l.weights[i * inputs + j] = 0.1 * (i + 1);
            printf("%f ", l.weights[i * inputs + j]);
        }
        printf("\n");
    }
}
void add_input_layer(network *net)
{
    int groups = 1;
    int batch,h,w,c;
    h = 1;
    w = 7;
    c = 1;
    batch=1;

    input_layer layer = make_input_layer(batch, h, w, c, groups);
    net->layers[0] = layer;
    net->inputs = h * w * c;
    if (net->workspace_size < layer.workspace_size) {
        net->workspace_size = layer.workspace_size;
    }
    int i,j,k;
    printf("input:\n");
    for (i = 0; i < layer.c; i++) {
        for (j = 0; j < layer.h; j++) {
            for (k = 0; k < layer.w; k++) {
                layer.output[(i * layer.w * layer.h) + j * layer.w + k] = (j + 1) * (k + 1) * 0.1;
                printf("%f ", layer.output[(i * layer.w * layer.h) + j * layer.w + k]);
            }
            printf("\n");
        }
        printf("\n");
    }
}

int main()
{
    int ret = 0;
    network *net;

    net = make_network(2);
    add_input_layer(net);
    add_connected_layer(net);
    forward_network(net);

    layer l = net->layers[1];
    printf("output:\n");
    int i,j;
    for (i = 0; i < l.outputs; i++) {
        printf("%f ", l.output[i]);
    }
    printf("\n");

    return ret;
}